fix(api): warn when the deployed schema does not match schema.prisma - #88
fix(api): warn when the deployed schema does not match schema.prisma#88github-actions[bot] wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/setup.md">
<violation number="1" location="docs/setup.md:134">
P3: The reconcile command uses `--to-schema prisma/schema.prisma`, which only resolves when run from inside `packages/db` — the repo root has no `prisma/schema.prisma` and no `prisma.config.ts`, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from `packages/db` (or using the full `packages/db/prisma/schema.prisma` path and the config), so the command is reproducible.</violation>
</file>
<file name="apps/api/scripts/build-func.mjs">
<violation number="1" location="apps/api/scripts/build-func.mjs:197">
P2: The drift diff output is captured with `spawnSync` and all defaults, which caps both stdout and stderr at Node's 1 MiB `maxBuffer`. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via `drift.stdout` grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, `spawnSync` throws a `RangeError: stdout maxBuffer length exceeded` and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising `maxBuffer` (and, optionally, explicitly treating a spawn failure so it still only warns).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| console.log("✓ migrations applied"); | ||
|
|
||
| console.log("• checking the deployed schema against schema.prisma..."); | ||
| const drift = spawnSync( |
There was a problem hiding this comment.
P2: The drift diff output is captured with spawnSync and all defaults, which caps both stdout and stderr at Node's 1 MiB maxBuffer. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via drift.stdout grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, spawnSync throws a RangeError: stdout maxBuffer length exceeded and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising maxBuffer (and, optionally, explicitly treating a spawn failure so it still only warns).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/scripts/build-func.mjs, line 197:
<comment>The drift diff output is captured with `spawnSync` and all defaults, which caps both stdout and stderr at Node's 1 MiB `maxBuffer`. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via `drift.stdout` grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, `spawnSync` throws a `RangeError: stdout maxBuffer length exceeded` and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising `maxBuffer` (and, optionally, explicitly treating a spawn failure so it still only warns).</comment>
<file context>
@@ -182,11 +182,52 @@ if (!process.env.VERCEL) {
console.log("✓ migrations applied");
+
+ console.log("• checking the deployed schema against schema.prisma...");
+ const drift = spawnSync(
+ bun,
+ [
</file context>
| Reconciling is one command, and it is worth reading before running: | ||
|
|
||
| ```sh | ||
| DATABASE_URL="…" bunx prisma migrate diff \ |
There was a problem hiding this comment.
P3: The reconcile command uses --to-schema prisma/schema.prisma, which only resolves when run from inside packages/db — the repo root has no prisma/schema.prisma and no prisma.config.ts, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from packages/db (or using the full packages/db/prisma/schema.prisma path and the config), so the command is reproducible.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/setup.md, line 134:
<comment>The reconcile command uses `--to-schema prisma/schema.prisma`, which only resolves when run from inside `packages/db` — the repo root has no `prisma/schema.prisma` and no `prisma.config.ts`, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from `packages/db` (or using the full `packages/db/prisma/schema.prisma` path and the config), so the command is reproducible.</comment>
<file context>
@@ -113,6 +113,28 @@ builds, and the pages that touch them fail. Test schema changes locally, where
+Reconciling is one command, and it is worth reading before running:
+
+```sh
+DATABASE_URL="…" bunx prisma migrate diff \
+ --from-config-datasource --to-schema prisma/schema.prisma --script
+```
</file context>
Opened automatically when
lewis/schema-drift-checkwas pushed.The title is written from the diff and rewritten as you push, because this is squashed onto
mainand the title becomes the commit subject and the changelog line. Retitle it yourself and it is yours — the automation stops touching it.